package cn.com.dhcc.turbo.entity.registry.tlq;

import java.util.List;

import cn.com.dhcc.app.core.util.StrUtil;
import cn.com.dhcc.app.pub.core.consts.TlqConfig;
import cn.com.dhcc.turbo.entity.registry.Queue;

import com.tongtech.tlq.admin.conf.LocalQue;
import com.tongtech.tlq.admin.conf.TlqConfException;

/**
 * 本地队列
 */
public class TlqLq extends Queue {
	private String queueName; //[名称 ]
	private String status; //[状态 ]状态值参考 TLQOptBaseObj定义"OBJ_STATE"类成员 
	private String configMsgNum; //[配置消息数 ]	 
	private String usedMsgNum; //[队列消息数 ]	 
	private String remainMsgNum; //[剩余消息数 ]	 
	private String mallocSpace; //[所占空间 ](单位K) 
	private String remainSpace; //[剩余空间 ](单位K)
	private String gettor; //[等待消费者数 ] 
	private String usageType; //[使用类型 ]TLQOptBaseObj定义"LQCALQUE_USETYPE"类成员	 
	private String trigType; //[触发类型 ]"N":None;"F":OnFirst;"E":OnEvery;"A":OnAmount;"D":OnDirect
	private String trigProgId; //[触发程序编号 ]

	public TlqLq() {
	}

	@SuppressWarnings("rawtypes")
	public TlqLq(List list) {
		this.queueName = "" + list.get(0);
		this.status = "" + list.get(1);
		this.configMsgNum = "" + list.get(2);
		this.usedMsgNum = "" + list.get(3);
		this.remainMsgNum = "" + list.get(4);
		this.mallocSpace = "" + list.get(5);
		this.remainSpace = "" + list.get(6);
		this.gettor = "" + list.get(7);
		this.usageType = "" + list.get(8);
		this.trigType = "" + list.get(9);
		this.trigProgId = "" + list.get(10);
	}

	/**
	 * 创建默认的本地队列（最大100条消息，单个消息最大10M）
	 * @param queName
	 * @return
	 * @throws TlqConfException
	 * @throws IllegalArgumentException
	 */
	public LocalQue toLocalQueDefaultParam() throws TlqConfException, IllegalArgumentException {
		if (StrUtil.isBlank(this.getQueueName())) {
			throw new IllegalArgumentException("LocalQueName can't be null");
		}
		LocalQue lq = new LocalQue();
		lq.setLocalQueName(this.getQueueName());
		lq.setMsgNum(TlqConfig.LQ.MSG_NUM);
		lq.setMsgSize(TlqConfig.LQ.MSG_SIZE);
		lq.setQueSpaceSize(TlqConfig.LQ.QUE_SPACE_SIZE);
		lq.setLocalQueDataBuff(TlqConfig.LQ.LOCAL_QUE_DATA_BUFF);
		lq.setMsgArrangeMode(TlqConfig.LQ.MSG_ARRANGE_MODE);
		lq.setUsageType(TlqConfig.LQ.USAGE_TYPE);
		lq.setDefPriority(TlqConfig.LQ.DEF_PRIORITY);
		lq.setDefPersistence(TlqConfig.LQ.DEF_PERSISTENCE);
		lq.setTrigType(TlqConfig.LQ.TRIG_TYPE);
		lq.setTrigProgId(TlqConfig.LQ.TRIG_PROG_ID);
		lq.setTrigAmount(TlqConfig.LQ.TRIG_AMOUNT);
		lq.setDeadFlag(TlqConfig.LQ.DEAD_FLAG);
		return lq;
	}

	public String getQueueName() {
		return queueName;
	}

	public String getStatus() {
		return status;
	}

	public String getConfigMsgNum() {
		return configMsgNum;
	}

	public String getUsedMsgNum() {
		return usedMsgNum;
	}

	public String getRemainMsgNum() {
		return remainMsgNum;
	}

	public String getMallocSpace() {
		return mallocSpace;
	}

	public String getRemainSpace() {
		return remainSpace;
	}

	public String getGettor() {
		return gettor;
	}

	public String getUsageType() {
		return usageType;
	}

	public String getTrigType() {
		return trigType;
	}

	public String getTrigProgId() {
		return trigProgId;
	}

	public void setQueueName(String queueName) {
		this.queueName = queueName;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public void setConfigMsgNum(String configMsgNum) {
		this.configMsgNum = configMsgNum;
	}

	public void setUsedMsgNum(String usedMsgNum) {
		this.usedMsgNum = usedMsgNum;
	}

	public void setRemainMsgNum(String remainMsgNum) {
		this.remainMsgNum = remainMsgNum;
	}

	public void setMallocSpace(String mallocSpace) {
		this.mallocSpace = mallocSpace;
	}

	public void setRemainSpace(String remainSpace) {
		this.remainSpace = remainSpace;
	}

	public void setGettor(String gettor) {
		this.gettor = gettor;
	}

	public void setUsageType(String usageType) {
		this.usageType = usageType;
	}

	public void setTrigType(String trigType) {
		this.trigType = trigType;
	}

	public void setTrigProgId(String trigProgId) {
		this.trigProgId = trigProgId;
	}

	@Override
	public String toString() {
		return "TlqLq [queueName=" + queueName + ", status=" + status + ", configMsgNum=" + configMsgNum
				+ ", usedMsgNum=" + usedMsgNum + ", remainMsgNum=" + remainMsgNum + ", mallocSpace=" + mallocSpace
				+ ", remainSpace=" + remainSpace + ", gettor=" + gettor + ", usageType=" + usageType + ", trigType="
				+ trigType + ", trigProgId=" + trigProgId + "]";
	}
}
